package com.itheima.Test.TreeSet;

import java.util.Comparator;
import java.util.TreeSet;

public class TreeSetDemo01 {
    public static void main(String[] args) {
        TreeSet<Student> ts=new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result=o2.getAge()-o1.getAge();
                result=result==0?o1.getName().compareTo(o2.getName()):result;
                return result;
            }
        });
        Student stu1=new Student("zs",18);
        Student stu2=new Student("zss",24);
        Student stu3=new Student("zzs",18);
        ts.add(stu1);
        ts.add(stu2);
        ts.add(stu3);
        System.out.println(ts);
    }
}
